<template>
  <div>
    <div class="header_search_nav search_form">
      <div class="ipt_left">
        <el-form ref="queryForm" :model="queryParams" label-width="80px">
          <el-row>
            <el-col :span="6">
              <el-form-item label="门店" prop="storeId">
                <el-select
                  v-model="queryParams.storeId"
                  filterable
                  placeholder="请选择"
                >
                  <el-option
                    v-for="(item, index) in $store.state.user.stores"
                    :key="index"
                    :label="item.name"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="6">
              <div class="timebox">
                <el-form-item label="日期时间" prop="date">
                  <timer
                    :Option="['beforeMonth', 'nextMonth']"
                    ref="timer"
                    dateType="daterange"
                    :timer.sync="queryParams.date"
                    @query="handleQuery"
                    :format="'yyyy-MM-dd'"
                    :isCheck="false"
                  ></timer>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <div class="btn_right">
        <button class="btn1" @click="handleQuery">筛选</button>
        <button class="btn2" @click="resetQuery">重置</button>
      </div>
    </div>
  </div>
</template>
          
    <script>
import { getFinanceTurnover, getFinanceTurnoverSum } from "@/api/bpm/reports";
import timer from "@/components/getTime/timer";
export default {
  name: "EryuoaStoreFrontendTodayReportList",
  components: { timer },
  data() {
    return {
      TotalRevenuetList: [],
      loading: false,
      value: "",
      total: 0,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        storeId: "",
        date: [],
        startDate: "",
        endDate: "",
      },
      totalSum: {},
    };
  },

  mounted() {},

  created() {},

  methods: {
    // 筛选
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.resetFormData("queryForm");
      // this.queryParams.localDate = dayDataTime("obj").str;
      this.handleQuery();
    },

    // 表单重置
    resetFormData(formName) {
      console.log(this.$refs[formName]);
      this.$nextTick(() => {
        this.$refs[formName].resetFields();
      });
    },

    // 门店日报表
    getList() {
      if (!!this.queryParams.date && this.queryParams.date.length === 0) {
        this.$message({
          message: "请选择日期时间",
          type: "error",
        });
        return false;
      }
      this.loading = true;
      const query = JSON.parse(JSON.stringify(this.queryParams));

      if (!!query.date) {
        query.startDate = this.queryParams.date[0];
        query.endDate = this.queryParams.date[1];
      }
      delete query.date;

      getFinanceTurnover(query)
        .then((res) => {
          this.loading = false;
          const { code, data } = res;
          if (code === 0) {
            this.TotalRevenuetList = data.list;
            this.total = data.total;

            this.getTotal(query);
          }
        })
        .catch((err) => {
          this.loading = false;
        });
    },

    getTotal(query) {
      getFinanceTurnoverSum(query)
        .then((res) => {
          const { code, data } = res;
          if (code === 0) {
            this.totalSum = data;
          }
        })
        .catch((err) => {});
    },
  },
};
</script>
          
          <style lang="scss" scoped>
.solid_left1 {
  margin-left: 24px;
}
.goodTop {
  width: 100%;
  height: 48px;
  background: #ffffff;
  display: flex;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.6);
  line-height: 48px;
  padding-left: 16px;
  .good_list {
    margin-right: 32px;
  }

  .good_active {
    color: #0052d9;
    border-bottom: 1px solid #0052d9;
  }
}

.w-200 {
  width: 200px;
  background: #ffffff;
  border-radius: 4px;
}

.client_name {
  font-size: 14px;
  font-weight: 400;
  color: #0052d9;
}

.give {
  height: 40px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
  margin-top: 40px;
  line-height: 40px;
}

.el-form-item {
  margin-bottom: 20px;
}

.recharge_form {
  padding: 10px 24px;
}

.memberName {
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
}
.el_row_item {
  margin-bottom: 10px;
}
.el_row_date {
  margin-top: 20px;
}
.el_row_reason {
  margin-top: 10px;
}

.el_row_date {
  .el-form-item {
    margin-bottom: 0px;
  }
}

.Order_box {
  display: flex;
  margin-left: -50px;
  .select_ipt {
    width: 130px;
    margin-right: 10px;
  }
}

.pay_ipt {
  margin-left: 50px;
}

.order_ipt {
  margin-left: -120px;
}

.timebox {
  margin-top: 10px;
}
</style>
          